import Ajax from '../../../lib/ajax';

import {Module, ActionContext} from 'vuex';

interface SessionState {
    application: any,
    user: any,

}

class SessionModule implements Module<SessionState, any> {
    namespaced = true;
    state = {
        application: null,
        user: null,

    };
    actions = {
        async init(context: ActionContext<SessionState, any>) {
            const response = await Ajax.get('/api/services/app/Session/GetCurrentLoginInformations');
            context.state.application = response.data.result.application;
            context.state.user = response.data.result.user;
        },
    };
}

const sessionModule = new SessionModule();
export default sessionModule;
